VERSION 5.00

Begin VB.Form FrmAlergenos 
   BorderStyle     =   4  'Fixed ToolWindow
   Caption         =   "Form1"
   ClientHeight    =   8355
   ClientLeft      =   1215
   ClientTop       =   1470
   ClientWidth     =   14025
   Icon            =   "frmAlergenos.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   8355
   ScaleWidth      =   14025
   ShowInTaskbar   =   0   'False
   WindowState     =   2  'Maximized
   Begin VB.TextBox Text1 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      BorderStyle     =   0  'None
      BeginProperty Font 
         Name            =   "Eras Bold ITC"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Left            =   4440
      Locked          =   -1  'True
      TabIndex        =   21
      Top             =   0
      Width           =   3495
   End
   Begin VB.TextBox Text2 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      BorderStyle     =   0  'None
      BeginProperty Font 
         Name            =   "Eras Bold ITC"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      HideSelection   =   0   'False
      Left            =   11160
      Locked          =   -1  'True
      TabIndex        =   20
      Top             =   600
      Width           =   2055
   End
   Begin VB.TextBox Text3 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      BorderStyle     =   0  'None
      BeginProperty Font 
         Name            =   "Eras Bold ITC"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      HideSelection   =   0   'False
      Left            =   4440
      Locked          =   -1  'True
      TabIndex        =   19
      Top             =   600
      Width           =   3495
   End
   Begin VB.TextBox Text4 
      BackColor       =   &H00E0E0E0&
      BorderStyle     =   0  'None
      BeginProperty Font 
         Name            =   "Eras Bold ITC"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   4440
      Locked          =   -1  'True
      TabIndex        =   18
      Top             =   960
      Width           =   3495
   End
   Begin VB.TextBox Text5 
      BackColor       =   &H00E0E0E0&
      BorderStyle     =   0  'None
      BeginProperty Font 
         Name            =   "Eras Bold ITC"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   4440
      Locked          =   -1  'True
      TabIndex        =   17
      Top             =   1320
      Width           =   3495
   End
   Begin VB.TextBox Text7 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      BorderStyle     =   0  'None
      BeginProperty Font 
         Name            =   "Eras Bold ITC"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   4440
      Locked          =   -1  'True
      TabIndex        =   16
      Top             =   1680
      Width           =   3495
   End
   Begin VB.TextBox Text11 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      BorderStyle     =   0  'None
      BeginProperty Font 
         Name            =   "Eras Bold ITC"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      HideSelection   =   0   'False
      Left            =   11160
      TabIndex        =   15
      Top             =   960
      Width           =   2055
   End
   Begin VB.ListBox List6 
      BackColor       =   &H00C0FFFF&
      Height          =   2595
      Left            =   8640
      TabIndex        =   14
      Top             =   4800
      Width           =   1215
   End
   Begin VB.CommandButton Command12 
      Height          =   495
      Left            =   6120
      Picture         =   "frmAlergenos.frx":030A
      Style           =   1  'Graphical
      TabIndex        =   9
      Top             =   7680
      Visible         =   0   'False
      Width           =   615
   End
   Begin VB.CommandButton Command11 
      Caption         =   "Command11"
      Height          =   375
      Left            =   12840
      TabIndex        =   8
      Top             =   4200
      Width           =   495
   End
   Begin VB.CommandButton Command6 
      Height          =   495
      Left            =   7920
      Picture         =   "frmAlergenos.frx":0894
      Style           =   1  'Graphical
      TabIndex        =   7
      Top             =   7680
      Width           =   615
   End
   Begin VB.CommandButton Command3 
      Height          =   495
      Left            =   6720
      Picture         =   "frmAlergenos.frx":0D96
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   7680
      Width           =   615
   End
   Begin VB.ListBox List2 
      BackColor       =   &H00C0FFFF&
      Height          =   2595
      Left            =   7440
      TabIndex        =   3
      Top             =   4800
      Width           =   1215
   End
   Begin VB.ListBox List1 
      BackColor       =   &H00C0FFFF&
      Height          =   2595
      Left            =   1800
      TabIndex        =   2
      Top             =   4800
      Width           =   5655
   End
   Begin VB.ListBox List4 
      Height          =   645
      Left            =   600
      TabIndex        =   1
      Top             =   4800
      Visible         =   0   'False
      Width           =   975
   End
   Begin VB.ListBox List5 
      BackColor       =   &H00C0FFFF&
      Height          =   2595
      Left            =   9840
      TabIndex        =   0
      Top             =   4800
      Width           =   3855
   End
   Begin VB.Label SkinLabel7 
      Height          =   255
      Index           =   3
      Left            =   8640
      Caption   =   "frmAlergenos.frx":15D6
      TabIndex        =   12
      Top             =   4560
      Width           =   1215
   End
   Begin VB.Label SkinLabel7 
      Height          =   255
      Index           =   4
      Left            =   9840
      Caption   =   "frmAlergenos.frx":1648
      TabIndex        =   13
      Top             =   4560
      Width           =   3735
   End
   Begin VB.CommandButton Command5 
      Height          =   495
      Left            =   7320
      Picture         =   "frmAlergenos.frx":16BC
      Style           =   1  'Graphical
      TabIndex        =   6
      Top             =   7680
      Width           =   615
   End
   Begin VB.ListBox List3 
      BackColor       =   &H00C0FFFF&
      Height          =   255
      Left            =   2040
      TabIndex        =   4
      Top             =   -600
      Visible         =   0   'False
      Width           =   1215
   End
   Begin VB.Label SkinLabel4 
      Height          =   375
      Index           =   0
      Left            =   2400
      Caption   =   "frmAlergenos.frx":1C56
      TabIndex        =   22
      Top             =   600
      Width           =   1935
   End
   Begin VB.Label SkinLabel3 
      Height          =   255
      Left            =   8400
      Caption   =   "frmAlergenos.frx":1CC6
      TabIndex        =   23
      Top             =   960
      Width           =   2415
   End
   Begin VB.Label SkinLabel2 
      Height          =   255
      Left            =   8400
      Caption   =   "frmAlergenos.frx":1D46
      TabIndex        =   24
      Top             =   600
      Width           =   2775
   End
   Begin VB.Label SkinLabel1 
      Height          =   255
      Left            =   2400
      Caption   =   "frmAlergenos.frx":1DCA
      TabIndex        =   25
      Top             =   0
      Width           =   1935
   End
   Begin VB.Label SkinLabel5 
      Height          =   255
      Left            =   2400
      Caption   =   "frmAlergenos.frx":1E36
      TabIndex        =   26
      Top             =   960
      Width           =   1935
   End
   Begin VB.Label SkinLabel6 
      Height          =   255
      Left            =   2400
      Caption   =   "frmAlergenos.frx":1EA4
      TabIndex        =   27
      Top             =   1320
      Width           =   1935
   End
   Begin VB.Label SkinLabel8 
      Height          =   255
      Left            =   2400
      Caption   =   "frmAlergenos.frx":1F10
      TabIndex        =   28
      Top             =   1680
      Width           =   1935
   End
End
Attribute VB_Name = "FrmAlergenos"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Pedido
Dim sta
Sub Grabar()
    Dim t As DAO.Recordset
    Dim D As DAO.Recordset
    Set t = Base.OpenRecordset("Alergenos ENC")
    Set D = Base.OpenRecordset("Alergenos DET")
    t.Index = "pedido"
    t.Seek "=", Text1.Text
    If t.NoMatch Then
        t.AddNew
        e = AutoNumero("cod_Alergenos", "Alergenos enc")
        t(0) = e
    Else
        t.Edit
        e = t(0)
        Base.Execute "delete from [Alergenos det] where cod_Alergenos =" & t(0)
    End If
            t(1) = Text1.Text
            t(2) = Date
            t(3) = Time
        t.Update
        
        For i = 0 To List1.ListCount - 1
            D.AddNew
                D(0) = e
                D(1) = List4.List(i)
                D(2) = List2.List(i)
                D(3) = List5.List(i)
                D("cod_relacion") = Val(List3.List(i))
                Base.Execute "update detalles set st='" & sta & "'where cod_detalle=" & List4.List(i)
            D.Update
        Next
End Sub
Sub Mostrardetalle()
    
    
    
    Dim t As DAO.Recordset
    Dim D As DAO.Recordset
    Set t = Base.OpenRecordset("Alergenos ENC")
    Set D = Base.OpenRecordset("Alergenos DET")
    List1.Clear
    List2.Clear
'    List3.Clear
   
    t.Index = "pedido"
    t.Seek "=", Text1.Text
    Dim x As DAO.Recordset
    
    If Not t.EOF Then
        Set t = Base.OpenRecordset("select *from Alergenos where cod_pedido=" & Pedido & " AND idGrupo=14 AND st<>'p'")
    ya = False
        While Not t.EOF
           If Not ya Then
            Set x = Base.OpenRecordset("select *from perfilemade  where cod_examen=" & t(1))
                ya = True
            End If
            On Error Resume Next
           If Not EsPerfilRes(t("COD_EXAMEN")) Then
                List1.AddItem t("descripcion")
                List3.AddItem " "
                List4.AddItem t("cod_detalle")
                BuscarValor t("resultado"), r, c
                List6.AddItem r
                If IsNull(t("observacion")) Then
                    List5.AddItem " "
                Else
                    List5.AddItem c
                End If

                List2.AddItem r
                ya = False
            Else
                
                List1.AddItem x("EXAMENES_1.descripcion")
                List3.AddItem x("cod_examenr")
                BuscarValor FrmElegir.res, r, c
                List6.AddItem r
                List4.AddItem t("cod_detalle")
                List5.AddItem c
                List2.AddItem t("resultado")
                
                x.MoveNext
                If x.EOF Then ya = False
            End If
            t.MoveNext
    Wend
        
    End If

    

    Set t = Base.OpenRecordset("select *from [Quimica FALTAN] where cod_pedido=" & Pedido & " AND idGrupo=14 AND st='p'")
    While Not t.EOF
        If Not EsPerfilRes(t("COD_EXAMEN")) Then
            List1.AddItem t("descripcion")
            ''List3.AddItem t("valor")
            List4.AddItem t("cod_detalle")
            FrmElegir.Label1.Caption = t("descripcion")
            ''FrmElegir.Label3.Caption = t("valor")
            FrmElegir.Show vbModal
            List5.AddItem FrmElegir.ob
            List2.AddItem FrmElegir.res: BorrarNoElegidos Me
        Else
            Dim made As DAO.Recordset
            Set made = Base.OpenRecordset("select *from PerfileMade where cod_examen=" & t("COD_EXAMEN"))
            On Error Resume Next
            While Not made.EOF
                List1.AddItem made("EXAMENES_1.descripcion")
                List3.AddItem made("cod_Examenr")
                BuscarValor FrmElegir.res, r, c
                List6.AddItem r
                List5.AddItem c
                
                List4.AddItem t("cod_detalle")
                FrmElegir.Label1.Caption = made("EXAMENES_1.descripcion")
                ''FrmElegir.Label3.Caption = t("valor")
                FrmElegir.Show vbModal
                'List5.AddItem FrmElegir.ob
                List2.AddItem FrmElegir.res: BorrarNoElegidos Me
                made.MoveNext
            Wend
        
        End If
        t.MoveNext
    Wend
    
End Sub

Sub MostrarEncabezado(t As DAO.Recordset)
    Dim TP As DAO.Recordset
    Set TP = Base.OpenRecordset("select *from paciente where cod_paciente=" & t("cod_paciente"))
    If Not TP.EOF Then
        Text1.Text = t("cod_pedido")
        Text2.Text = t("fecha")
        Text3.Text = t("PacienteNro")
        Text4.Text = TP("nombres")
        Text5.Text = TP("cedula")
        'Text6.Text = TP("direccion")
        Text7.Text = t("descrip_pedido")
        Dim x As DAO.Recordset
'        Set X = Base.OpenRecordset("select *from [Alergenos ResultadoE] where cod_pedido= " & t("cod_pedido"))
 '       If Not X.EOF Then
  '          Text11.Text = X("fecha")
   '     Else
            Text11.Text = Date
    '    End If
    End If
End Sub
Sub BuscarEncabezado()
    Dim t As DAO.Recordset
    Set t = Base.OpenRecordset("select *from pedido where cod_pedido=" & Val(Text1.Text))
    If t.EOF Then
    Else
        MostrarEncabezado t
    End If
End Sub

Private Sub Command3_Click()
    Auditar "Guardar", "Alergenos", Text1.Text
    sta = "g"
    Grabar
End Sub

Private Sub Command5_Click()
    sta = "i"
    Grabar
'    Set FrmReporte.Report = New rptAlergenos
    'f = "{pedido.cod_pedido}=" & Text1.Text
    'FrmReporte.Report.RecordSelectionFormula = f
    'FrmReporte.Report.ParameterFields.GetItemByName("nombrelab").AddCurrentValue (NombreLab)
    'FrmReporte.Report.ReadRecords
    'FrmReporte.Show vbModal
End Sub

Private Sub Command6_Click()
    Unload Me: ActGestor
End Sub

Private Sub Form_Load()
    Text1.Text = Pedido
    BuscarEncabezado
    Mostrardetalle
    AplicarSkin Me
    Me.Caption = titulo2("Alergenos")
End Sub
Sub Seleccionar(i): On Error Resume Next
On Error Resume Next
    List1.Selected(i) = True
    List2.Selected(i) = True
    List3.Selected(i) = True
    List4.Selected(i) = True
    List5.Selected(i) = True
End Sub

Private Sub Label10_Click()

End Sub

Private Sub List1_Click()
    Seleccionar List1.ListIndex
End Sub

Private Sub List1_DblClick()
    On Error Resume Next
        FrmElegir.Label1.Caption = List1.List(List1.ListIndex)
        FrmElegir.Label3.Caption = List3.List(List1.ListIndex): FrmElegir.Text1.Text = List2.List(List1.ListIndex): FrmElegir.Text2.Text = List5.List(List1.ListIndex)
    FrmElegir.Show vbModal
    
    List5.List(List1.ListIndex) = FrmElegir.ob
    List2.List(List1.ListIndex) = FrmElegir.res

End Sub



